<template>
  <div v-show="status" class="trolley">
    <!-- 遮罩层 -->
    <div class="mask_layer"></div>

    <main>
      <div class="cunut">

        <div class="clear">
          <h4>商品列表</h4>
          <span>
            <van-icon name="delete-o" color="red" @click='clear' />清空
          </span>
        </div>

        <div class="ma">
          <div class="shopping" v-for="(item,index) in shopcarDatatata" :key="index">
            <div class="left">
              <div class="img">
                <img :src="item.picture" alt="">
              </div>
            </div>
            <div class="main">
              <h4>{{item.name}}</h4>
              <div class="money">￥<span>{{item.min_price}}</span></div>
            </div>
            <div class="right">
              <div class="but">

                <button @click="sub(item)">-</button>
                <input type="text" value="1">
                <button>+</button>
              </div>
            </div>
          </div>

          <div class="if_else">
            <span v-show="shopcarDatatata.length == 0">购物车空空如也<span class="zheng">去整点</span></span>
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";

export default {
  mounted() {
    setTimeout(() => {
      console.log(this.shopcarDatatata);
    }, 1500);
  },
  computed: {
    ...mapState(['shopcarDatatata']),
  },
  data() {
    return {
      status: false,
    }
  },
  methods: {

    ...mapActions(['clear', 'sub']),
    add() {
      this.status = !this.status
    }
  },
}
</script>

<style lang='scss' scoped>
.if_else {
  width: 100%;
  height: 300px;
  // background-color: rebeccapurple;
  display: flex;
  justify-content: center;
  align-items: center;
  .zheng {
    color: orange;
  }
}
.ma {
  width: 100%;
  height: 100%;
  justify-content: center;
  //   display: flex;
  box-sizing: border-box;
  .shopping {
    display: flex;
    width: 90%;
    height: 130px;
    margin: 0 auto;
    // background-color: aqua;
    .left {
      width: 30%;
      height: 100%;
      //   background-color: pink;
      justify-content: center;
      display: flex;
      align-items: center;
      .img {
        width: 80%;
        height: 80%;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
    .main {
      width: 40%;
      height: 100%;
      //   background-color: rosybrown;
      h4 {
        margin-top: 10px;
        margin-bottom: 70px;
      }
      .money {
        color: red;
        span {
          color: red;
          font-size: 20px;
        }
      }
    }
    .right {
      flex: 1;
      height: 100%;
      //   background-color: bisque;
      position: relative;
      .but {
        position: absolute;
        bottom: 0;
        width: 100%;
        height: 40px;
        // background-color: aqua;
        display: flex;
        padding-left: 20px;
        justify-content: space-between;
        align-items: center;
      }
      button:nth-child(1) {
        border-radius: 50%;
        width: 20px;
        height: 20px;
        line-height: 6px;
        font-size: 20px;
        border: 1px solid #9cffff;
      }
      input {
        border-radius: 50%;
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        outline: none;
        border: none;
      }
      button:nth-child(3) {
        border-radius: 50%;
        font-size: 20px;
        line-height: 4px;
        width: 20px;
        background-color: #9cffff;
        height: 20px;
      }
    }
  }
}

main {
  width: 100%;
  height: 70%;
  display: flex;
  justify-content: center;

  .cunut {
    width: 100%;
    height: 100%;
    background-color: #fff;

    .clear {
      width: 100%;
      height: 30px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }
}
.trolley {
  width: 100%;
  height: 90%;
  position: fixed;
  top: 0;
  .mask_layer {
    width: 100%;
    height: 200px;
    background-color: rgba(128, 128, 128, 0.749);
  }
}
</style>